Prereq: "4.0p1"
*** ../tk4.0p1/patchlevel.h	Fri Jul 28 10:08:41 1995
--- patchlevel.h	Mon Sep 18 11:42:16 1995
***************
*** 17,23 ****
   * See the file "license.terms" for information on usage and redistribution
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   *
!  * @(#) patchlevel.h 1.8 95/07/18 16:23:42
   */
  
! #define TK_PATCH_LEVEL "4.0p1"
--- 17,23 ----
   * See the file "license.terms" for information on usage and redistribution
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   *
!  * @(#) patchlevel.h 1.9 95/09/18 11:42:14
   */
  
! #define TK_PATCH_LEVEL "4.0p2"
*** ../tk4.0p1/./tkEvent.c	Wed Jun 21 15:16:37 1995
--- ./tkEvent.c	Mon Aug 28 09:33:14 1995
***************
*** 14,20 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkEvent.c 1.97 95/06/21 15:16:33";
  
  #include "tkPort.h"
  #include "tkInt.h"
--- 14,20 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkEvent.c 1.98 95/08/28 09:33:14";
  
  #include "tkPort.h"
  #include "tkInt.h"
***************
*** 261,267 ****
      register FileHandler *filePtr;
      int index;
  
!     if (fd >= OPEN_MAX) {
  	panic("Tk_CreatefileHandler can't handle file id %d", fd);
      }
  
--- 261,267 ----
      register FileHandler *filePtr;
      int index;
  
!     if (fd >= FD_SETSIZE) {
  	panic("Tk_CreatefileHandler can't handle file id %d", fd);
      }
  
*** ../tk4.0p1/./tkFont.c	Sun Jun  4 15:27:43 1995
--- ./tkFont.c	Wed Aug 16 10:27:56 1995
***************
*** 13,19 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkFont.c 1.36 95/06/04 15:27:43";
  
  #include "tkPort.h"
  #include "tkInt.h"
--- 13,19 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkFont.c 1.37 95/08/16 10:27:54";
  
  #include "tkPort.h"
  #include "tkInt.h"
***************
*** 572,578 ****
  	if (newX > maxX) {
  	    break;
  	}
! 	c = p[1] & 0xff;
  	if (isspace(UCHAR(c)) || (c == 0)) {
  	    term = p+1;
  	    termX = newX;
--- 572,582 ----
  	if (newX > maxX) {
  	    break;
  	}
! 	if (maxChars > 1) {
! 	    c = p[1] & 0xff;
! 	} else {
! 	    c = 0;
! 	}
  	if (isspace(UCHAR(c)) || (c == 0)) {
  	    term = p+1;
  	    termX = newX;
*** ../tk4.0p1/./tkSelect.c	Thu May 11 09:37:18 1995
--- ./tkSelect.c	Mon Aug 21 10:49:15 1995
***************
*** 12,18 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkSelect.c 1.47 95/05/11 09:37:15";
  
  #include "tkPort.h"
  #include "tkInt.h"
--- 12,18 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkSelect.c 1.48 95/08/21 10:49:09";
  
  #include "tkPort.h"
  #include "tkInt.h"
***************
*** 488,496 ****
  	infoPtr->owner = tkwin;
  	infoPtr->nextPtr = dispPtr->selectionInfoPtr;
  	dispPtr->selectionInfoPtr = infoPtr;
!     } else if ((infoPtr->owner != tkwin) && (infoPtr->clearProc != NULL)) {
! 	clearProc = infoPtr->clearProc;
! 	clearData = infoPtr->clearData;
      }
  
      infoPtr->owner = tkwin;
--- 488,506 ----
  	infoPtr->owner = tkwin;
  	infoPtr->nextPtr = dispPtr->selectionInfoPtr;
  	dispPtr->selectionInfoPtr = infoPtr;
!     } else if (infoPtr->clearProc != NULL) {
! 	if (infoPtr->owner != tkwin) {
! 	    clearProc = infoPtr->clearProc;
! 	    clearData = infoPtr->clearData;
! 	} else if (infoPtr->clearProc == LostSelection) {
! 	    /*
! 	     * If the selection handler is one created by "selection own",
! 	     * be sure to free the record for it;  otherwise there will be
! 	     * a memory leak.
! 	     */
! 
! 	    ckfree((char *) infoPtr->clearData);
! 	}
      }
  
      infoPtr->owner = tkwin;
*** ../tk4.0p1/./tkSend.c	Wed Jul 26 17:13:26 1995
--- ./tkSend.c	Mon Aug 21 10:49:15 1995
***************
*** 12,18 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkSend.c 1.49 95/07/26 17:13:25";
  
  #include "tkPort.h"
  #include "tkInt.h"
--- 12,18 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkSend.c 1.50 95/08/21 10:49:10";
  
  #include "tkPort.h"
  #include "tkInt.h"
***************
*** 65,74 ****
  				 * been modified, so it needs to be written
  				 * out when the NameRegistry is closed. */
      unsigned long propLength;	/* Length of the property, in bytes. */
!     char *property;		/* The contents of the property.  See format
! 				 * above;  this is *not* terminated by the
! 				 * first null character.  Dynamically
! 				 * allocated. */
      int allocedByX;		/* Non-zero means must free property with
  				 * XFree;  zero means use ckfree. */
  } NameRegistry;
--- 65,74 ----
  				 * been modified, so it needs to be written
  				 * out when the NameRegistry is closed. */
      unsigned long propLength;	/* Length of the property, in bytes. */
!     char *property;		/* The contents of the property, or NULL
! 				 * if none.  See format description above;
! 				 * this is *not* terminated by the first
! 				 * null character.  Dynamically allocated. */
      int allocedByX;		/* Non-zero means must free property with
  				 * XFree;  zero means use ckfree. */
  } NameRegistry;
***************
*** 328,334 ****
      /*
       * Xlib placed an extra null byte after the end of the property, just
       * to make sure that it is always NULL-terminated.  Be sure to include
!      * this byte in our count if it's needed to ensure null termination.
       */
  
      if ((regPtr->propLength > 0)
--- 328,336 ----
      /*
       * Xlib placed an extra null byte after the end of the property, just
       * to make sure that it is always NULL-terminated.  Be sure to include
!      * this byte in our count if it's needed to ensure null termination
!      * (note: as of 8/95 I'm no longer sure why this code is needed;  seems
!      * like it shouldn't be).
       */
  
      if ((regPtr->propLength > 0)
***************
*** 455,461 ****
   *	None.
   *
   * Side effects:
!  *	The open registry is exapanded;  it is marked as modified so that
   *	it will be written back when closed.
   *
   *----------------------------------------------------------------------
--- 457,463 ----
   *	None.
   *
   * Side effects:
!  *	The open registry is expanded;  it is marked as modified so that
   *	it will be written back when closed.
   *
   *----------------------------------------------------------------------
***************
*** 481,487 ****
      newProp = (char *) ckalloc((unsigned) (regPtr->propLength + newBytes));
      strcpy(newProp, id);
      strcpy(newProp+idLength, name);
!     if (regPtr->propLength > 0) {
  	memcpy((VOID *) (newProp + newBytes), (VOID *) regPtr->property,
  		regPtr->propLength);
  	if (regPtr->allocedByX) {
--- 483,489 ----
      newProp = (char *) ckalloc((unsigned) (regPtr->propLength + newBytes));
      strcpy(newProp, id);
      strcpy(newProp+idLength, name);
!     if (regPtr->property != NULL) {
  	memcpy((VOID *) (newProp + newBytes), (VOID *) regPtr->property,
  		regPtr->propLength);
  	if (regPtr->allocedByX) {
***************
*** 537,543 ****
      }
      XFlush(regPtr->dispPtr->display);
  
!     if (regPtr->propLength > 0) {
  	if (regPtr->allocedByX) {
  	    XFree(regPtr->property);
  	} else {
--- 539,545 ----
      }
      XFlush(regPtr->dispPtr->display);
  
!     if (regPtr->property != NULL) {
  	if (regPtr->allocedByX) {
  	    XFree(regPtr->property);
  	} else {
*** ../tk4.0p1/./tkVisual.c	Tue May  9 13:47:46 1995
--- ./tkVisual.c	Wed Aug 16 10:43:49 1995
***************
*** 12,18 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkVisual.c 1.12 95/05/09 13:47:42";
  
  #include "tkInt.h"
  #include "tkPort.h"
--- 12,18 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkVisual.c 1.13 95/08/16 10:43:48";
  
  #include "tkInt.h"
  #include "tkPort.h"
***************
*** 313,318 ****
--- 313,319 ----
  	    cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin),
  		    RootWindowOfScreen(Tk_Screen(tkwin)), visual,
  		    AllocNone);
+ 	    cmapPtr->visual = NULL;
  	    cmapPtr->refCount = 1;
  	    cmapPtr->shareable = 1;
  	    cmapPtr->nextPtr = dispPtr->cmapPtr;
*** ../tk4.0p1/./tkWm.c	Sat Jul 22 16:04:58 1995
--- ./tkWm.c	Mon Aug 21 10:49:16 1995
***************
*** 13,19 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkWm.c 1.107 95/07/22 16:04:57";
  
  #include "tkPort.h"
  #include "tkInt.h"
--- 13,19 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkWm.c 1.108 95/08/21 10:49:12";
  
  #include "tkPort.h"
  #include "tkInt.h"
***************
*** 840,845 ****
--- 840,846 ----
  		    Tcl_AppendElement(interp, winPtr2->pathName);
  		}
  	    }
+ 	    XFree((char *) cmapList);
  	    return TCL_OK;
  	}
  	if (Tcl_SplitList(interp, argv[3], &windowArgc, &windowArgv)
*** ../tk4.0p1/./tkMenu.c	Sat Jul 22 16:05:26 1995
--- ./tkMenu.c	Sat Aug 26 17:21:15 1995
***************
*** 13,19 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkMenu.c 1.93 95/07/22 16:05:23";
  
  #include "tkPort.h"
  #include "default.h"
--- 13,19 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkMenu.c 1.94 95/08/26 17:21:13";
  
  #include "tkPort.h"
  #include "default.h"
***************
*** 1741,1755 ****
  		    bgBorder, menuPtr->borderWidth, mePtr->y,
  		    Tk_Width(tkwin) - 2*menuPtr->borderWidth, mePtr->height,
  		    menuPtr->activeBorderWidth, TK_RELIEF_RAISED);
- 	    gc = mePtr->activeGC;
- 	    if (gc == NULL) {
- 		gc = menuPtr->activeGC;
- 	    }
  	} else {
  	    Tk_Fill3DRectangle(menuPtr->tkwin, Tk_WindowId(tkwin),
  		    bgBorder, menuPtr->borderWidth, mePtr->y,
  		    Tk_Width(tkwin) - 2*menuPtr->borderWidth, mePtr->height,
  		    0, TK_RELIEF_FLAT);
  	    if ((mePtr->state == tkDisabledUid)
  		    && (menuPtr->disabledFg != NULL)) {
  		gc = mePtr->disabledGC;
--- 1741,1763 ----
  		    bgBorder, menuPtr->borderWidth, mePtr->y,
  		    Tk_Width(tkwin) - 2*menuPtr->borderWidth, mePtr->height,
  		    menuPtr->activeBorderWidth, TK_RELIEF_RAISED);
  	} else {
  	    Tk_Fill3DRectangle(menuPtr->tkwin, Tk_WindowId(tkwin),
  		    bgBorder, menuPtr->borderWidth, mePtr->y,
  		    Tk_Width(tkwin) - 2*menuPtr->borderWidth, mePtr->height,
  		    0, TK_RELIEF_FLAT);
+ 	}
+ 
+ 	/*
+ 	 * Choose the gc for drawing the foreground part of the entry.
+ 	 */
+ 
+ 	if ((mePtr->state == tkActiveUid) && !strictMotif) {
+ 	    gc = mePtr->activeGC;
+ 	    if (gc == NULL) {
+ 		gc = menuPtr->activeGC;
+ 	    }
+ 	} else {
  	    if ((mePtr->state == tkDisabledUid)
  		    && (menuPtr->disabledFg != NULL)) {
  		gc = mePtr->disabledGC;
*** ../tk4.0p1/./tkCanvas.c	Thu Jul 27 13:23:50 1995
--- ./tkCanvas.c	Wed Aug 16 09:42:14 1995
***************
*** 12,18 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkCanvas.c 1.101 95/07/27 13:23:48";
  
  #include "default.h"
  #include "tkInt.h"
--- 12,18 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkCanvas.c 1.103 95/08/16 09:42:13";
  
  #include "default.h"
  #include "tkInt.h"
***************
*** 311,316 ****
--- 311,317 ----
      canvasPtr->drawableXOrigin = canvasPtr->drawableYOrigin = 0;
      canvasPtr->bindingTable = NULL;
      canvasPtr->currentItemPtr = NULL;
+     canvasPtr->newCurrentPtr = NULL;
      canvasPtr->closeEnough = 0.0;
      canvasPtr->pickEvent.type = LeaveNotify;
      canvasPtr->pickEvent.xcrossing.x = 0;
***************
*** 771,776 ****
--- 772,781 ----
  		    canvasPtr->currentItemPtr = NULL;
  		    canvasPtr->flags |= REPICK_NEEDED;
  		}
+ 		if (itemPtr == canvasPtr->newCurrentPtr) {
+ 		    canvasPtr->newCurrentPtr = NULL;
+ 		    canvasPtr->flags |= REPICK_NEEDED;
+ 		}
  		if (itemPtr == canvasPtr->textInfo.focusItemPtr) {
  		    canvasPtr->textInfo.focusItemPtr = NULL;
  		}
***************
*** 2882,2888 ****
  					 * LeaveWindow, ButtonRelease, or
  					 * MotionNotify. */
  {
-     Tk_Item *closestPtr = NULL;
      double coords[2];
      int buttonDown;
  
--- 2887,2892 ----
***************
*** 2957,2965 ****
      coords[0] = canvasPtr->pickEvent.xcrossing.x + canvasPtr->xOrigin;
      coords[1] = canvasPtr->pickEvent.xcrossing.y + canvasPtr->yOrigin;
      if (canvasPtr->pickEvent.type != LeaveNotify) {
! 	closestPtr = CanvasFindClosest(canvasPtr, coords);
      }
  
      /*
       * Simulate a LeaveNotify event on the previous current item and
       * an EnterNotify event on the new current item.  Remove the "current"
--- 2961,2980 ----
      coords[0] = canvasPtr->pickEvent.xcrossing.x + canvasPtr->xOrigin;
      coords[1] = canvasPtr->pickEvent.xcrossing.y + canvasPtr->yOrigin;
      if (canvasPtr->pickEvent.type != LeaveNotify) {
! 	canvasPtr->newCurrentPtr = CanvasFindClosest(canvasPtr, coords);
!     } else {
! 	canvasPtr->newCurrentPtr = NULL;
      }
  
+     if ((canvasPtr->newCurrentPtr == canvasPtr->currentItemPtr)
+ 	    && !(canvasPtr->flags & LEFT_GRABBED_ITEM)) {
+ 	/*
+ 	 * Nothing to do:  the current item hasn't changed.
+ 	 */
+ 
+ 	return;
+     }
+ 
      /*
       * Simulate a LeaveNotify event on the previous current item and
       * an EnterNotify event on the new current item.  Remove the "current"
***************
*** 2967,2973 ****
       * item.
       */
  
!     if ((closestPtr != canvasPtr->currentItemPtr)
  	    && (canvasPtr->currentItemPtr != NULL)
  	    && !(canvasPtr->flags & LEFT_GRABBED_ITEM)) {
  	XEvent event;
--- 2982,2988 ----
       * item.
       */
  
!     if ((canvasPtr->newCurrentPtr != canvasPtr->currentItemPtr)
  	    && (canvasPtr->currentItemPtr != NULL)
  	    && !(canvasPtr->flags & LEFT_GRABBED_ITEM)) {
  	XEvent event;
***************
*** 3004,3034 ****
  	}
      
  	/*
! 	 * The binding for the leave event could have changed the canvas such
! 	 * that closestPtr should no longer be the new current item.  In fact,
! 	 * closestPtr may not even exist anymore.  The only safe thing is to
! 	 * recompute the new current item.  Even the mouse position may have
! 	 * changed, so recompute coords.
  	 */
- 
- 	coords[0] = canvasPtr->pickEvent.xcrossing.x + canvasPtr->xOrigin;
- 	coords[1] = canvasPtr->pickEvent.xcrossing.y + canvasPtr->yOrigin;
- 	buttonDown = canvasPtr->state
- 		& (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask);
- 	if (canvasPtr->pickEvent.type != LeaveNotify) {
- 	    closestPtr = CanvasFindClosest(canvasPtr, coords);
- 	}
      }
!     if ((closestPtr != canvasPtr->currentItemPtr) && buttonDown) {
  	canvasPtr->flags |= LEFT_GRABBED_ITEM;
  	return;
      }
!     if ((closestPtr == canvasPtr->currentItemPtr)
! 	    && !(canvasPtr->flags & LEFT_GRABBED_ITEM)) {
! 	return;
!     }
      canvasPtr->flags &= ~LEFT_GRABBED_ITEM;
!     canvasPtr->currentItemPtr = closestPtr;
      if (canvasPtr->currentItemPtr != NULL) {
  	XEvent event;
  
--- 3019,3042 ----
  	}
      
  	/*
! 	 * Note:  during CanvasDoEvent above, it's possible that
! 	 * canvasPtr->newCurrentPtr got reset to NULL because the
! 	 * item was deleted.
  	 */
      }
!     if ((canvasPtr->newCurrentPtr != canvasPtr->currentItemPtr) && buttonDown) {
  	canvasPtr->flags |= LEFT_GRABBED_ITEM;
  	return;
      }
! 
!     /*
!      * Special note:  it's possible that canvasPtr->newCurrentPtr ==
!      * canvasPtr->currentItemPtr here.  This can happen, for example,
!      * if LEFT_GRABBED_ITEM was set.
!      */
! 
      canvasPtr->flags &= ~LEFT_GRABBED_ITEM;
!     canvasPtr->currentItemPtr = canvasPtr->newCurrentPtr;
      if (canvasPtr->currentItemPtr != NULL) {
  	XEvent event;
  
*** ../tk4.0p1/./tkCanvPs.c	Mon Jun 19 10:05:00 1995
--- ./tkCanvPs.c	Fri Aug  4 10:05:09 1995
***************
*** 12,18 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkCanvPs.c 1.35 95/06/19 10:04:58";
  
  #include <stdio.h>
  #include "tkInt.h"
--- 12,18 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkCanvPs.c 1.36 95/08/04 10:05:08";
  
  #include <stdio.h>
  #include "tkInt.h"
***************
*** 767,777 ****
      }
      strncpy(fontName, fieldPtrs[FAMILY_FIELD], (size_t) nameSize);
      if (islower(UCHAR(fontName[0]))) {
! 	fontName[0] = toupper(fontName[0]);
      }
      for (p = fontName+1, i = nameSize-1; i > 0; p++, i--) {
  	if (isupper(UCHAR(*p))) {
! 	    *p = tolower(*p);
  	}
      }
      *p = 0;
--- 767,777 ----
      }
      strncpy(fontName, fieldPtrs[FAMILY_FIELD], (size_t) nameSize);
      if (islower(UCHAR(fontName[0]))) {
! 	fontName[0] = toupper(UCHAR(fontName[0]));
      }
      for (p = fontName+1, i = nameSize-1; i > 0; p++, i--) {
  	if (isupper(UCHAR(*p))) {
! 	    *p = tolower(UCHAR(*p));
  	}
      }
      *p = 0;
*** ../tk4.0p1/./tkImgFmtPPM.c	Wed Jul 26 12:57:37 1995
--- ./tkImgFmtPPM.c	Wed Aug 30 15:34:53 1995
***************
*** 14,20 ****
   *	   Australian National University.
   */
  
! static char sccsid[] = "@(#) tkImgFmtPPM.c 1.8 95/07/26 12:57:36";
  
  #include "tkInt.h"
  #include "tkPort.h"
--- 14,20 ----
   *	   Australian National University.
   */
  
! static char sccsid[] = "@(#) tkImgFmtPPM.c 1.9 95/08/30 15:34:52";
  
  #include "tkInt.h"
  #include "tkPort.h"
***************
*** 381,388 ****
  	    }
  	    c = getc(f);
  	}
! 	buffer[i] = ' ';
! 	i++;
  	firstInLine = 0;
      }
      buffer[i] = 0;
--- 381,390 ----
  	    }
  	    c = getc(f);
  	}
! 	if (i < (BUFFER_SIZE-1)) {
! 	    buffer[i] = ' ';
! 	    i++;
! 	}
  	firstInLine = 0;
      }
      buffer[i] = 0;
*** ../tk4.0p1/./tkImgPhoto.c	Tue Jul 25 15:55:28 1995
--- ./tkImgPhoto.c	Mon Aug 28 14:01:06 1995
***************
*** 16,22 ****
   *	   Australian National University.
   */
  
! static char sccsid[] = "@(#) tkImgPhoto.c 1.27 95/07/25 15:55:25";
  
  #include "tkInt.h"
  #include "tkPort.h"
--- 16,22 ----
   *	   Australian National University.
   */
  
! static char sccsid[] = "@(#) tkImgPhoto.c 1.29 95/08/28 14:01:04";
  
  #include "tkInt.h"
  #include "tkPort.h"
***************
*** 2993,3004 ****
      matched = 0;
      for (formatPtr = formatList; formatPtr != NULL;
  	 formatPtr = formatPtr->nextPtr) {
! 	if ((formatString != NULL)
! 		&& (strncasecmp(formatString, formatPtr->name,
! 		strlen(formatPtr->name)) != 0)) {
! 	    continue;
  	}
- 	matched = 1;
  	if (formatPtr->fileMatchProc != NULL) {
  	    fseek(f, 0L, SEEK_SET);
  	    if ((*formatPtr->fileMatchProc)(f, fileName, formatString,
--- 2993,3010 ----
      matched = 0;
      for (formatPtr = formatList; formatPtr != NULL;
  	 formatPtr = formatPtr->nextPtr) {
! 	if (formatString != NULL) {
! 	    if (strncasecmp(formatString, formatPtr->name,
! 		    strlen(formatPtr->name)) != 0) {
! 		continue;
! 	    }
! 	    matched = 1;
! 	    if (formatPtr->fileMatchProc == NULL) {
! 		Tcl_AppendResult(interp, "-file option isn't supported for ",
! 			formatString, " images", (char *) NULL);
! 		return TCL_ERROR;
! 	    }
  	}
  	if (formatPtr->fileMatchProc != NULL) {
  	    fseek(f, 0L, SEEK_SET);
  	    if ((*formatPtr->fileMatchProc)(f, fileName, formatString,
***************
*** 3017,3023 ****
      if (formatPtr == NULL) {
  	if ((formatString != NULL) && !matched) {
  	    Tcl_AppendResult(interp, "image file format \"", formatString,
! 		    "\" is unknown", (char *) NULL);
  	} else {
  	    Tcl_AppendResult(interp,
  		    "couldn't recognize data in image file \"",
--- 3023,3029 ----
      if (formatPtr == NULL) {
  	if ((formatString != NULL) && !matched) {
  	    Tcl_AppendResult(interp, "image file format \"", formatString,
! 		    "\" is not supported", (char *) NULL);
  	} else {
  	    Tcl_AppendResult(interp,
  		    "couldn't recognize data in image file \"",
***************
*** 3072,3085 ****
       * Scan through the table of file format handlers to find
       * one which can handle the image.
       */
      matched = 0;
      for (formatPtr = formatList; formatPtr != NULL;
  	    formatPtr = formatPtr->nextPtr) {
! 	if ((formatString != NULL) && (strncasecmp(formatString,
! 		formatPtr->name, strlen(formatPtr->name)) != 0)) {
! 	    continue;
  	}
- 	matched = 1;
  	if ((formatPtr->stringMatchProc != NULL)
  		&& (*formatPtr->stringMatchProc)(string, formatString,
  		widthPtr, heightPtr)) {
--- 3078,3099 ----
       * Scan through the table of file format handlers to find
       * one which can handle the image.
       */
+ 
      matched = 0;
      for (formatPtr = formatList; formatPtr != NULL;
  	    formatPtr = formatPtr->nextPtr) {
! 	if (formatString != NULL) {
! 	    if (strncasecmp(formatString, formatPtr->name,
! 		    strlen(formatPtr->name)) != 0) {
! 		continue;
! 	    }
! 	    matched = 1;
! 	    if (formatPtr->stringMatchProc == NULL) {
! 		Tcl_AppendResult(interp, "-data option isn't supported for ",
! 			formatString, " images", (char *) NULL);
! 		return TCL_ERROR;
! 	    }
  	}
  	if ((formatPtr->stringMatchProc != NULL)
  		&& (*formatPtr->stringMatchProc)(string, formatString,
  		widthPtr, heightPtr)) {
***************
*** 3089,3099 ****
  
      if (formatPtr == NULL) {
  	if ((formatString != NULL) && !matched) {
! 	    Tcl_AppendResult(interp, "image file format \"", formatString,
! 		    "\" is unknown", (char *) NULL);
  	} else {
! 	    Tcl_AppendResult(interp, "no format found to parse",
! 		    " image data string", (char *) NULL);
  	}
  	return TCL_ERROR;
      }
--- 3103,3113 ----
  
      if (formatPtr == NULL) {
  	if ((formatString != NULL) && !matched) {
! 	    Tcl_AppendResult(interp, "image format \"", formatString,
! 		    "\" is not supported", (char *) NULL);
  	} else {
! 	    Tcl_AppendResult(interp, "couldn't recognize image data",
! 		    (char *) NULL);
  	}
  	return TCL_ERROR;
      }
***************
*** 3191,3197 ****
      xEnd = x + width;
      yEnd = y + height;
      if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
! 	ImgPhotoSetSize(masterPtr, xEnd, yEnd);
      }
  
      if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY)
--- 3205,3212 ----
      xEnd = x + width;
      yEnd = y + height;
      if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
! 	ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width),
! 		MAX(yEnd, masterPtr->height));
      }
  
      if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY)
***************
*** 3228,3234 ****
  		&& (blockPtr->pitch == pitch)))) {
  	memcpy((VOID *) destLinePtr,
  		(VOID *) (blockPtr->pixelPtr + blockPtr->offset[0]),
! 		(size_t) (height * pitch));
      } else {
  	for (hLeft = height; hLeft > 0;) {
  	    srcLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
--- 3243,3249 ----
  		&& (blockPtr->pitch == pitch)))) {
  	memcpy((VOID *) destLinePtr,
  		(VOID *) (blockPtr->pixelPtr + blockPtr->offset[0]),
! 		(size_t) (height * width * 3));
      } else {
  	for (hLeft = height; hLeft > 0;) {
  	    srcLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
***************
*** 3347,3353 ****
      xEnd = x + width;
      yEnd = y + height;
      if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
! 	ImgPhotoSetSize(masterPtr, xEnd, yEnd);
      }
  
      if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY)
--- 3362,3369 ----
      xEnd = x + width;
      yEnd = y + height;
      if ((xEnd > masterPtr->width) || (yEnd > masterPtr->height)) {
! 	ImgPhotoSetSize(masterPtr, MAX(xEnd, masterPtr->width),
! 		MAX(yEnd, masterPtr->height));
      }
  
      if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY)
***************
*** 3956,3962 ****
  	height = masterPtr->height;
      }
      if ((width != masterPtr->width) || (height != masterPtr->height)) {
! 	ImgPhotoSetSize(masterPtr, width, height);
  	Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width,
  		masterPtr->height);
      }
--- 3972,3979 ----
  	height = masterPtr->height;
      }
      if ((width != masterPtr->width) || (height != masterPtr->height)) {
! 	ImgPhotoSetSize(masterPtr, MAX(width, masterPtr->width),
! 		MAX(height, masterPtr->height));
  	Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width,
  		masterPtr->height);
      }
*** ../tk4.0p1/./tkText.c	Thu Jul 20 09:42:41 1995
--- ./tkText.c	Mon Aug 21 11:46:28 1995
***************
*** 14,20 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkText.c 1.80 95/07/20 09:42:42";
  
  #include "default.h"
  #include "tkPort.h"
--- 14,20 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkText.c 1.82 95/08/21 11:46:27";
  
  #include "default.h"
  #include "tkPort.h"
***************
*** 279,284 ****
--- 279,286 ----
      textPtr->bindingTable = NULL;
      textPtr->currentMarkPtr = NULL;
      textPtr->pickEvent.type = LeaveNotify;
+     textPtr->pickEvent.xcrossing.x = 0;
+     textPtr->pickEvent.xcrossing.y = 0;
      textPtr->numCurTags = 0;
      textPtr->curTagArrayPtr = NULL;
      textPtr->takeFocus = NULL;
***************
*** 1547,1554 ****
      startingLine = TkBTreeLineIndex(index.linePtr);
      startingChar = index.charIndex;
      if (startingLine >= numLines) {
! 	startingLine = 0;
! 	startingChar = 0;
      }
      if (argsLeft == 1) {
  	if (TkTextGetIndex(interp, textPtr, argv[i+2], &stopIndex) != TCL_OK) {
--- 1549,1562 ----
      startingLine = TkBTreeLineIndex(index.linePtr);
      startingChar = index.charIndex;
      if (startingLine >= numLines) {
! 	if (backwards) {
! 	    startingLine = TkBTreeNumLines(textPtr->tree) - 1;
! 	    startingChar = TkBTreeCharsInLine(TkBTreeFindLine(textPtr->tree,
! 		    startingLine));
! 	} else {
! 	    startingLine = 0;
! 	    startingChar = 0;
! 	}
      }
      if (argsLeft == 1) {
  	if (TkTextGetIndex(interp, textPtr, argv[i+2], &stopIndex) != TCL_OK) {
*** ../tk4.0p1/./tkTextIndex.c	Wed Jun 28 16:16:36 1995
--- ./tkTextIndex.c	Mon Sep 18 13:26:54 1995
***************
*** 11,17 ****
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkTextIndex.c 1.11 95/06/28 16:16:36";
  
  #include "default.h"
  #include "tkPort.h"
--- 11,17 ----
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   */
  
! static char sccsid[] = "@(#) tkTextIndex.c 1.12 95/09/18 13:26:52";
  
  #include "default.h"
  #include "tkPort.h"
***************
*** 522,528 ****
      while (isspace(UCHAR(*p))) {
  	p++;
      }
!     count = strtoul(p, &end, 0);
      if (end == p) {
  	return NULL;
      }
--- 522,528 ----
      while (isspace(UCHAR(*p))) {
  	p++;
      }
!     count = strtol(p, &end, 0);
      if (end == p) {
  	return NULL;
      }
*** ../tk4.0p1/./tkCanvas.h	Sat Mar 18 16:47:24 1995
--- ./tkCanvas.h	Wed Aug 16 09:39:37 1995
***************
*** 10,16 ****
   * See the file "license.terms" for information on usage and redistribution
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   *
!  * @(#) tkCanvas.h 1.36 95/03/18 16:47:07
   */
  
  #ifndef _TKCANVAS
--- 10,16 ----
   * See the file "license.terms" for information on usage and redistribution
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   *
!  * @(#) tkCanvas.h 1.37 95/08/16 09:39:35
   */
  
  #ifndef _TKCANVAS
***************
*** 122,127 ****
--- 122,133 ----
  				 * the address of an item named by id. */
      Tk_Item *currentItemPtr;	/* The item currently containing the mouse
  				 * pointer, or NULL if none. */
+     Tk_Item *newCurrentPtr;	/* The item that is about to become the
+ 				 * current one, or NULL.  This field is
+ 				 * used to detect deletions  of the new
+ 				 * current item pointer that occur during
+ 				 * Leave processing of the previous current
+ 				 * item.  */
      double closeEnough;		/* The mouse is assumed to be inside an
  				 * item if it is this close to it. */
      XEvent pickEvent;		/* The event upon which the current choice
*** ../tk4.0p1/./tkPort.h	Thu May 11 10:49:36 1995
--- ./tkPort.h	Mon Aug 28 09:33:15 1995
***************
*** 11,17 ****
   * See the file "license.terms" for information on usage and redistribution
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   *
!  * @(#) tkPort.h 1.5 95/05/11 10:49:35
   */
  
  #ifndef _TKPORT
--- 11,17 ----
   * See the file "license.terms" for information on usage and redistribution
   * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
   *
!  * @(#) tkPort.h 1.6 95/08/28 09:33:16
   */
  
  #ifndef _TKPORT
***************
*** 79,92 ****
  extern int errno;
  
  /*
-  * Define OPEN_MAX if it isn't already defined for this system.
-  */
- 
- #ifndef OPEN_MAX
- #   define OPEN_MAX 256
- #endif
- 
- /*
   * The following macro defines the type of the mask arguments to
   * select:
   */
--- 79,84 ----
***************
*** 116,129 ****
   * The following macro defines the number of fd_masks in an fd_set:
   */
  
  #if !defined(howmany)
  #   define howmany(x, y) (((x)+((y)-1))/(y))
  #endif
! #ifdef NFDBITS
! #   define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
! #else
! #   define MASK_SIZE howmany(OPEN_MAX, NBBY*sizeof(fd_mask))
  #endif
  
  /*
   * The following macro checks to see whether there is buffered
--- 108,127 ----
   * The following macro defines the number of fd_masks in an fd_set:
   */
  
+ #ifndef FD_SETSIZE
+ #   ifdef OPEN_MAX
+ #	define FD_SETSIZE OPEN_MAX
+ #   else
+ #	define FD_SETSIZE 256
+ #   endif
+ #endif
  #if !defined(howmany)
  #   define howmany(x, y) (((x)+((y)-1))/(y))
  #endif
! #ifndef NFDBITS
! #   define NFDBITS NBBY*sizeof(fd_mask)
  #endif
+ #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
  
  /*
   * The following macro checks to see whether there is buffered
*** ../tk4.0p1/./changes	Fri Jul 28 10:20:44 1995
--- ./changes	Mon Sep 18 13:27:53 1995
***************
*** 2,8 ****
  released on March 13, 1991.  Changes that aren't backward compatible
  are marked specially.
  
! sccsid = %Z% %M% %I% %E% %U%
  
  3/16/91 (bug fix) Modified tkWindow.c to remove Tk's Tcl commands from
  the interpreter when the main window is deleted (otherwise there will
--- 2,8 ----
  released on March 13, 1991.  Changes that aren't backward compatible
  are marked specially.
  
! sccsid = @(#) changes 1.23 95/09/18 13:27:50
  
  3/16/91 (bug fix) Modified tkWindow.c to remove Tk's Tcl commands from
  the interpreter when the main window is deleted (otherwise there will
***************
*** 2453,2455 ****
--- 2453,2511 ----
  posted.
  
  ----------------- Released patch 4.0p1, 7/29/95 ----------------------
+ 
+ 8/4/95 (bug fix) Calls to toupper and tolower weren't using the UCHAR
+ macro, so they didn't always work in non-U.S. locales. (JO)
+ 
+ 8/16/95 (bug fix) Canvases didn't generate proper Enter and Leave
+ events if the Leave handler for an item reconfigured the canvas in
+ a way that made the old current item the new current item again. (JO)
+ 
+ 8/21/95 (bug fixes) Fixed memory leaks in tkSend.c, tkSelect.c, and
+ tkWm.c (JO).
+ 
+ 8/21/95 (bug fix) Text widgets didn't handle commands like
+ ".t search -backwards foo end 1.0" properly:  never found foo.
+ 
+ 8/25/95 (bug fix) Fixed bug in libary/menu.tcl that caused "grab
+ window not visible" errors for popup menus (and perhaps elsewhere?). (JO)
+ 
+ 8/25/95 (bug fix) Scrollbar bindings didn't properly handle case where
+ B2 is clicked while B1 is already down. (JO)
+ 
+ 8/26/95 (bug fix) Menus were ignoring -activebackground if tk_strictMotif
+ was set, but not -activeforeground.  Changed to ignore both. (JO)
+ 
+ 8/26/95 (bug fix) Scales and scrollbars didn't properly handle a
+ -repeatdelay value of 0 (they shouldn't auto-repeat in this case). (JO)
+ 
+ 8/28/95 (bug fix) Tcl errors were occurring for tkPriv(oldGrab) when
+ clicking on a disabled option menu. (JO)
+ 
+ 8/28/95 (bug fix) Changed event-handling code to use FD_SETSIZE instead
+ of OPEN_MAX, since OPEN_MAX is incorrect on some systems (e.g., IRIX). (JO)
+ 
+ 8/28/95 (bug fix) Fixed bug in photo images that caused garbling of
+ image data in the "put" and "copy" commands if the source data had
+ only one scan line but had a width less than the width of the target
+ image. (JO)
+ 
+ 8/29/95 (bug fix) Tk used to refuse to post menus if they had no
+ entries.  This made it impossible for a menu to fill itself the first
+ time it is posted.  Changed to allow menus with no entries to be
+ posted. (JO)
+ 
+ 8/30/95 (new features) Added proper button 2 support to both scrollbars
+ and scales (it sets the slider position from the mouse position). (JO)
+ 
+ 8/30/95 (bug fix) Fixed potential core dump that could occur in
+ photo images (ReadPPMFileHeader could overflow buffer under some bad
+ inputs, such as certain GIF images). (JO)
+ 
+ 8/39/95 (bug fix) Errors of the form `syntax error in expression "!"'
+ could occasionally happen in tkScaleDrag. (JO)
+ 
+ 9/19/95 (bug fix) Fixed bug in text index processing that causes
+ tests textIndex-11.1 and textIndex12.1 to fail on some platforms.
+ 
+ ----------------- Released patch 4.0p2, 9/19/95 ----------------------
*** ../tk4.0p1/./configure	Tue Jul 25 17:30:46 1995
--- ./configure	Mon Sep 18 11:08:13 1995
***************
*** 401,407 ****
  
  
  
! # @(#) configure.in 1.17 95/06/27 21:54:20
  
  ac_aux_dir=
  for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
--- 401,407 ----
  
  
  
! # @(#) configure.in 1.18 95/09/05 17:04:17
  
  ac_aux_dir=
  for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
***************
*** 1732,1738 ****
  #include <stdio.h>
  int main() { return 0; }
  int t() {
! FILE *f = stdin; f->_gptr = f->egptr;
  ; return 0; }
  EOF
  if eval $ac_compile; then
--- 1732,1738 ----
  #include <stdio.h>
  int main() { return 0; }
  int t() {
! FILE *f = stdin; f->_gptr = f->_egptr;
  ; return 0; }
  EOF
  if eval $ac_compile; then
*** ../tk4.0p1/./configure.in	Tue Jun 27 21:54:19 1995
--- ./configure.in	Tue Sep  5 17:04:17 1995
***************
*** 3,9 ****
  dnl	to configure the system for the local environment.
  AC_INIT(tk.h)
  
! # @(#) configure.in 1.17 95/06/27 21:54:20
  
  AC_PROG_INSTALL
  AC_PROG_RANLIB
--- 3,9 ----
  dnl	to configure the system for the local environment.
  AC_INIT(tk.h)
  
! # @(#) configure.in 1.18 95/09/05 17:04:17
  
  AC_PROG_INSTALL
  AC_PROG_RANLIB
***************
*** 224,230 ****
  fi
  if test "$fcnt" = ""; then
      AC_TRY_COMPILE([#include <stdio.h>],
! 	[FILE *f = stdin; f->_gptr = f->egptr;],
  	tk_ok=yes, tk_ok=no)
      if test $tk_ok = yes; then
  	AC_DEFINE(TK_FILE_GPTR)
--- 224,230 ----
  fi
  if test "$fcnt" = ""; then
      AC_TRY_COMPILE([#include <stdio.h>],
! 	[FILE *f = stdin; f->_gptr = f->_egptr;],
  	tk_ok=yes, tk_ok=no)
      if test $tk_ok = yes; then
  	AC_DEFINE(TK_FILE_GPTR)
*** ../tk4.0p1/./library/listbox.tcl	Tue Jul 25 13:24:34 1995
--- ./library/listbox.tcl	Tue Aug 22 08:49:49 1995
***************
*** 3,9 ****
  # This file defines the default bindings for Tk listbox widgets
  # and provides procedures that help in implementing those bindings.
  #
! # @(#) listbox.tcl 1.12 95/07/25 13:24:32
  #
  # Copyright (c) 1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
--- 3,9 ----
  # This file defines the default bindings for Tk listbox widgets
  # and provides procedures that help in implementing those bindings.
  #
! # @(#) listbox.tcl 1.13 95/08/22 08:49:50
  #
  # Copyright (c) 1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
***************
*** 26,33 ****
  # The code below creates the default class bindings for listboxes.
  #-------------------------------------------------------------------------
  
  bind Listbox <1> {
!     tkListboxBeginSelect %W [%W index @%x,%y]
  }
  bind Listbox <B1-Motion> {
      set tkPriv(x) %x
--- 26,41 ----
  # The code below creates the default class bindings for listboxes.
  #-------------------------------------------------------------------------
  
+ # Note: the check for existence of %W below is because this binding
+ # is sometimes invoked after a window has been deleted (e.g. because
+ # there is a double-click binding on the widget that deletes it).  Users
+ # can put "break"s in their bindings to avoid the error, but this check
+ # makes that unnecessary.
+ 
  bind Listbox <1> {
!     if [winfo exists %W] {
! 	tkListboxBeginSelect %W [%W index @%x,%y]
!     }
  }
  bind Listbox <B1-Motion> {
      set tkPriv(x) %x
*** ../tk4.0p1/./library/menu.tcl	Fri Jul 28 09:35:56 1995
--- ./library/menu.tcl	Tue Aug 29 17:33:54 1995
***************
*** 4,10 ****
  # It also implements keyboard traversal of menus and implements a few
  # other utility procedures related to menus.
  #
! # @(#) menu.tcl 1.52 95/07/28 09:35:55
  #
  # Copyright (c) 1992-1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
--- 4,10 ----
  # It also implements keyboard traversal of menus and implements a few
  # other utility procedures related to menus.
  #
! # @(#) menu.tcl 1.54 95/08/29 17:33:53
  #
  # Copyright (c) 1992-1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
***************
*** 213,219 ****
  	return
      }
      set menu [$w cget -menu]
!     if {($menu == "") || ([$menu index last] == "none")} {
  	return
      }
      if ![string match $w.* $menu] {
--- 213,219 ----
  	return
      }
      set menu [$w cget -menu]
!     if {$menu == ""} {
  	return
      }
      if ![string match $w.* $menu] {
***************
*** 431,437 ****
  		&& [winfo ismapped [winfo parent $menu]]} {
  	    set menu [winfo parent $menu]
  	}
! 	tkSaveGrabInfo $menu
  	grab -global $menu
      }
  }
--- 431,449 ----
  		&& [winfo ismapped [winfo parent $menu]]} {
  	    set menu [winfo parent $menu]
  	}
! 
! 	# Don't update grab information if the grab window isn't changing.
! 	# Otherwise, we'll get an error when we unpost the menus and
! 	# restore the grab, since the old grab window will not be viewable
! 	# anymore.
! 
! 	if {$menu != [grab current $menu]} {
! 	    tkSaveGrabInfo $menu
! 	}
! 
! 	# Must re-grab even if the grab window hasn't changed, in order
! 	# to release the implicit grab from the button press.
! 
  	grab -global $menu
      }
  }
*** ../tk4.0p1/./library/scale.tcl	Thu Jun  8 13:18:31 1995
--- ./library/scale.tcl	Wed Aug 30 09:46:56 1995
***************
*** 3,9 ****
  # This file defines the default bindings for Tk scale widgets and provides
  # procedures that help in implementing the bindings.
  #
! # @(#) scale.tcl 1.7 95/05/05 16:56:09
  #
  # Copyright (c) 1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
--- 3,9 ----
  # This file defines the default bindings for Tk scale widgets and provides
  # procedures that help in implementing the bindings.
  #
! # @(#) scale.tcl 1.9 95/08/30 09:46:57
  #
  # Copyright (c) 1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
***************
*** 50,56 ****
      tkScaleActivate %W %x %y
  }
  bind Scale <2> {
!     tkScaleButtonDown %W %x %y
  }
  bind Scale <B2-Motion> {
      tkScaleDrag %W %x %y
--- 50,56 ----
      tkScaleActivate %W %x %y
  }
  bind Scale <2> {
!     tkScaleButton2Down %W %x %y
  }
  bind Scale <B2-Motion> {
      tkScaleDrag %W %x %y
***************
*** 211,218 ****
  	set tkPriv(afterId) [after [$w cget -repeatinterval] \
  		tkScaleIncrement $w $dir $big again]
      } elseif {$repeat == "initial"} {
! 	set tkPriv(afterId) [after [$w cget -repeatdelay] \
! 		tkScaleIncrement $w $dir $big again]
      }
  }
  
--- 211,221 ----
  	set tkPriv(afterId) [after [$w cget -repeatinterval] \
  		tkScaleIncrement $w $dir $big again]
      } elseif {$repeat == "initial"} {
! 	set delay [$w cget -repeatdelay]
! 	if {$delay > 0} {
! 	    set tkPriv(afterId) [after $delay \
! 		    tkScaleIncrement $w $dir $big again]
! 	}
      }
  }
  
***************
*** 232,235 ****
--- 235,262 ----
      } elseif {$el == "trough2"} {
  	$w set [$w cget -to]
      }
+ }
+ 
+ # tkScaleButton2Down
+ # This procedure is invoked when button 2 is pressed over a scale.
+ # It sets the value to correspond to the mouse position and starts
+ # a slider drag.
+ #
+ # Arguments:
+ # w -		The scrollbar widget.
+ # x, y -	Mouse coordinates within the widget.
+ 
+ proc tkScaleButton2Down {w x y} {
+     global tkPriv
+ 
+     if {[$w cget -state] == "disabled"} {
+ 	return;
+     }
+     $w configure -state active
+     $w set [$w get $x $y]
+     set tkPriv(dragging) 1
+     set tkPriv(initValue) [$w get]
+     set coords "$x $y"
+     set tkPriv(deltaX) 0
+     set tkPriv(deltaY) 0
  }
*** ../tk4.0p1/./library/scrollbar.tcl	Thu Jun 29 14:03:05 1995
--- ./library/scrollbar.tcl	Tue Sep  5 15:19:07 1995
***************
*** 3,9 ****
  # This file defines the default bindings for Tk scrollbar widgets.
  # It also provides procedures that help in implementing the bindings.
  #
! # @(#) scrollbar.tcl 1.13 95/06/29 14:03:03
  #
  # Copyright (c) 1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
--- 3,9 ----
  # This file defines the default bindings for Tk scrollbar widgets.
  # It also provides procedures that help in implementing the bindings.
  #
! # @(#) scrollbar.tcl 1.18 95/09/05 15:19:08
  #
  # Copyright (c) 1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
***************
*** 40,45 ****
--- 40,48 ----
  bind Scrollbar <B1-Motion> {
      tkScrollDrag %W %x %y
  }
+ bind Scrollbar <B1-B2-Motion> {
+     tkScrollDrag %W %x %y
+ }
  bind Scrollbar <ButtonRelease-1> {
      tkScrollButtonUp %W %x %y
  }
***************
*** 50,57 ****
      # Prevents <Enter> binding from being invoked.
  }
  bind Scrollbar <2> {
!     tkScrollButtonDown %W %x %y
  }
  bind Scrollbar <B2-Motion> {
      tkScrollDrag %W %x %y
  }
--- 53,66 ----
      # Prevents <Enter> binding from being invoked.
  }
  bind Scrollbar <2> {
!     tkScrollButton2Down %W %x %y
  }
+ bind Scrollbar <B1-2> {
+     # Do nothing, since button 1 is already down.
+ }
+ bind Scrollbar <B2-1> {
+     # Do nothing, since button 2 is already down.
+ }
  bind Scrollbar <B2-Motion> {
      tkScrollDrag %W %x %y
  }
***************
*** 58,63 ****
--- 67,78 ----
  bind Scrollbar <ButtonRelease-2> {
      tkScrollButtonUp %W %x %y
  }
+ bind Scrollbar <B1-ButtonRelease-2> {
+     # Do nothing:  B1 release will handle it.
+ }
+ bind Scrollbar <B2-ButtonRelease-1> {
+     # Do nothing:  B2 release will handle it.
+ }
  bind Scrollbar <B2-Leave> {
      # Prevents <Leave> binding from being invoked.
  }
***************
*** 147,153 ****
  }
  
  # tkScrollSelect --
! # This procedure is invoked when button 1 is pressed over the scrollbar.
  # It invokes one of several scrolling actions depending on where in
  # the scrollbar the button was pressed.
  #
--- 162,168 ----
  }
  
  # tkScrollSelect --
! # This procedure is invoked when a button is pressed over the scrollbar.
  # It invokes one of several scrolling actions depending on where in
  # the scrollbar the button was pressed.
  #
***************
*** 177,184 ****
  	set tkPriv(afterId) [after [$w cget -repeatinterval] \
  		tkScrollSelect $w $element again]
      } elseif {$repeat == "initial"} {
! 	set tkPriv(afterId) [after [$w cget -repeatdelay] \
! 		tkScrollSelect $w $element again]
      }
  }
  
--- 192,201 ----
  	set tkPriv(afterId) [after [$w cget -repeatinterval] \
  		tkScrollSelect $w $element again]
      } elseif {$repeat == "initial"} {
! 	set delay [$w cget -repeatdelay]
! 	if {$delay > 0} {
! 	    set tkPriv(afterId) [after $delay tkScrollSelect $w $element again]
! 	}
      }
  }
  
***************
*** 354,357 ****
--- 371,404 ----
      } elseif [string match *2 $element] {
  	tkScrollToPos $w 1
      }
+ }
+ 
+ # tkScrollButton2Down
+ # This procedure is invoked when button 2 is pressed over a scrollbar.
+ # If the button is over the trough or slider, it sets the scrollbar to
+ # the mouse position and starts a slider drag.  Otherwise it just
+ # behaves the same as button 1.
+ #
+ # Arguments:
+ # w -		The scrollbar widget.
+ # x, y -	Mouse coordinates within the widget.
+ 
+ proc tkScrollButton2Down {w x y} {
+     global tkPriv
+     set element [$w identify $x $y]
+     if {($element == "arrow1") || ($element == "arrow2")} {
+ 	tkScrollButtonDown $w $x $y
+ 	return
+     }
+     tkScrollToPos $w [$w fraction $x $y]
+ 
+     # Need the "update idletasks" below so that the widget calls us
+     # back to reset the actual scrollbar position before we start the
+     # slider drag.
+ 
+     update idletasks
+     set tkPriv(relief) [$w cget -activerelief]
+     $w configure -activerelief sunken
+     $w activate slider
+     tkScrollStartDrag $w $x $y
  }
*** ../tk4.0p1/./library/tk.tcl	Wed Jun 21 09:20:14 1995
--- ./library/tk.tcl	Wed Aug 30 16:40:21 1995
***************
*** 3,9 ****
  # Initialization script normally executed in the interpreter for each
  # Tk-based application.  Arranges class bindings for widgets.
  #
! # @(#) tk.tcl 1.67 95/06/19 10:45:49
  #
  # Copyright (c) 1992-1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
--- 3,9 ----
  # Initialization script normally executed in the interpreter for each
  # Tk-based application.  Arranges class bindings for widgets.
  #
! # @(#) tk.tcl 1.73 95/08/30 16:40:20
  #
  # Copyright (c) 1992-1994 The Regents of the University of California.
  # Copyright (c) 1994-1995 Sun Microsystems, Inc.
***************
*** 52,58 ****
      set tkPriv(afterId) {}
      set tkPriv(buttons) 0
      set tkPriv(buttonWindow) {}
!     set tkPriv(dragging) {}
      set tkPriv(focus) {}
      set tkPriv(grab) {}
      set tkPriv(initPos) {}
--- 52,58 ----
      set tkPriv(afterId) {}
      set tkPriv(buttons) 0
      set tkPriv(buttonWindow) {}
!     set tkPriv(dragging) 0
      set tkPriv(focus) {}
      set tkPriv(grab) {}
      set tkPriv(initPos) {}
***************
*** 59,64 ****
--- 59,65 ----
      set tkPriv(inMenubutton) {}
      set tkPriv(listboxPrev) {}
      set tkPriv(mouseMoved) 0
+     set tkPriv(oldGrab) {}
      set tkPriv(popup) {}
      set tkPriv(postedMb) {}
      set tkPriv(pressX) 0
*** ../tk4.0p1/./doc/scale.n	Wed Jun  7 21:15:49 1995
--- ./doc/scale.n	Wed Aug 30 10:05:02 1995
***************
*** 5,14 ****
  '\" See the file "license.terms" for information on usage and redistribution
  '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  '\" 
! '\" @(#) scale.n 1.23 95/06/07 21:15:31
  '\" 
  .so man.macros
! .TH scale n 4.0 Tk "Tk Built-In Commands"
  .BS
  '\" Note:  do not modify the .SH NAME line immediately below!
  .SH NAME
--- 5,14 ----
  '\" See the file "license.terms" for information on usage and redistribution
  '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  '\" 
! '\" @(#) scale.n 1.24 95/08/30 10:05:01
  '\" 
  .so man.macros
! .TH scale n 4.1 Tk "Tk Built-In Commands"
  .BS
  '\" Note:  do not modify the .SH NAME line immediately below!
  .SH NAME
***************
*** 322,341 ****
  the slider moves all the way to the end of its range, in the
  direction towards the mouse cursor.
  .IP [4]
  The Up and Left keys move the slider up (left) by the value
  of the \fBresolution\fR option.
! .IP [5]
  The Down and Right keys move the slider down (right) by the value
  of the \fBresolution\fR option.
! .IP [6]
  Control-Up and Control-Left move the slider up (left) by the
  value of the \fBbigIncrement\fR option.
! .IP [7]
  Control-Down and Control-Right move the slider down (right) by the
  value of the \fBbigIncrement\fR option.
- .IP [8]
- Home moves the slider to the top (left) end of its range.
  .IP [9]
  End moves the slider to the bottom (right) end of its range.
  .PP
  If the scale is disabled using the \fBstate\fR option then
--- 322,345 ----
  the slider moves all the way to the end of its range, in the
  direction towards the mouse cursor.
  .IP [4]
+ If button 2 is pressed, the scale's value is set to the mouse
+ position.  If the mouse is dragged with button 2 down, the scale's
+ value changes with the drag.
+ .IP [5]
  The Up and Left keys move the slider up (left) by the value
  of the \fBresolution\fR option.
! .IP [6]
  The Down and Right keys move the slider down (right) by the value
  of the \fBresolution\fR option.
! .IP [7]
  Control-Up and Control-Left move the slider up (left) by the
  value of the \fBbigIncrement\fR option.
! .IP [8]
  Control-Down and Control-Right move the slider down (right) by the
  value of the \fBbigIncrement\fR option.
  .IP [9]
+ Home moves the slider to the top (left) end of its range.
+ .IP [10]
  End moves the slider to the bottom (right) end of its range.
  .PP
  If the scale is disabled using the \fBstate\fR option then
*** ../tk4.0p1/./doc/scrollbar.n	Thu Jun 29 14:25:22 1995
--- ./doc/scrollbar.n	Wed Aug 30 10:05:02 1995
***************
*** 5,14 ****
  '\" See the file "license.terms" for information on usage and redistribution
  '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  '\" 
! '\" @(#) scrollbar.n 1.23 95/06/29 14:25:20
  '\" 
  .so man.macros
! .TH scrollbar n 4.0 Tk "Tk Built-In Commands"
  .BS
  '\" Note:  do not modify the .SH NAME line immediately below!
  .SH NAME
--- 5,14 ----
  '\" See the file "license.terms" for information on usage and redistribution
  '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  '\" 
! '\" @(#) scrollbar.n 1.24 95/08/30 10:05:00
  '\" 
  .so man.macros
! .TH scrollbar n 4.1 Tk "Tk Built-In Commands"
  .BS
  '\" Note:  do not modify the .SH NAME line immediately below!
  .SH NAME
***************
*** 335,342 ****
  document appears to move up (left) one unit.
  If the button is held down, the action auto-repeats.
  .IP [6]
! All of the above actions may be invoked with button 2 as well
! as with button 1.
  .IP [7]
  If button 1 is pressed with the Control key down, then if the
  mouse is over \fBarrow1\fR or \fBtrough1\fR the view changes
--- 335,345 ----
  document appears to move up (left) one unit.
  If the button is held down, the action auto-repeats.
  .IP [6]
! If button 2 is pressed over the trough or the slider, it sets
! the view to correspond to the mouse position;  dragging the
! mouse with button 2 down causes the view to drag with the mouse.
! If button 2 is pressed over one of the arrows, it causes the
! same behavior as pressing button 1.
  .IP [7]
  If button 1 is pressed with the Control key down, then if the
  mouse is over \fBarrow1\fR or \fBtrough1\fR the view changes
*** ../tk4.0p1/./tests/imgPhoto.test	Wed Jun 21 15:50:08 1995
--- ./tests/imgPhoto.test	Mon Aug 28 09:52:10 1995
***************
*** 21,27 ****
  #
  # Author: Paul Mackerras (paulus@cs.anu.edu.au)
  #
! # @(#) imgPhoto.test 1.9 95/06/21 15:50:04
  
  if {[info procs test] != "test"} {
      source defs
--- 21,27 ----
  #
  # Author: Paul Mackerras (paulus@cs.anu.edu.au)
  #
! # @(#) imgPhoto.test 1.10 95/08/28 09:52:11
  
  if {[info procs test] != "test"} {
      source defs
***************
*** 52,58 ****
      list [catch {image create photo p1 -file \
  	    $tk_library/demos/images/teapot.ppm \
  	    -format no.such.format} err] $err
! } {1 {image file format "no.such.format" is unknown}}
  test imgPhoto-1.4 {options for photo images} {
      image create photo p1 -file $tk_library/demos/images/teapot.ppm
      list [image width p1] [image height p1]
--- 52,58 ----
      list [catch {image create photo p1 -file \
  	    $tk_library/demos/images/teapot.ppm \
  	    -format no.such.format} err] $err
! } {1 {image file format "no.such.format" is not supported}}
  test imgPhoto-1.4 {options for photo images} {
      image create photo p1 -file $tk_library/demos/images/teapot.ppm
      list [image width p1] [image height p1]
***************
*** 237,243 ****
  test imgPhoto-4.33 {ImgPhotoCmd procedure: read option} {
      list [catch {p1 read $tk_library/demos/images/teapot.ppm \
  	    -format bogus} err] $err
! } {1 {image file format "bogus" is unknown}}
  test imgPhoto-4.34 {ImgPhotoCmd procedure: read option} {
      list [catch {p1 read README} err] $err
  } {1 {couldn't recognize data in image file "README"}}
--- 237,243 ----
  test imgPhoto-4.33 {ImgPhotoCmd procedure: read option} {
      list [catch {p1 read $tk_library/demos/images/teapot.ppm \
  	    -format bogus} err] $err
! } {1 {image file format "bogus" is not supported}}
  test imgPhoto-4.34 {ImgPhotoCmd procedure: read option} {
      list [catch {p1 read README} err] $err
  } {1 {couldn't recognize data in image file "README"}}
